<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/fragment::top">

</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <div th:replace="common/fragment::leftmenu"></div>
        <!--End 左侧导航-->

        <!--头部信息-->
        <div th:replace="common/fragment::header"></div>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div>
                    <form action="#!" class="horizontal " id="add-user-form" method="post">

                        <!--用户名-->
                        <div class="form-group col-md-10 ">
                            <label class="col-md-2 control-label" for="stockname" style="text-align: center;line-height: 36px">库名</label>
                            <div class="col-md-8">
                                <input class="form-control" id="stockname" name="stockname"
                                       placeholder="库名" type="text">
                            </div>
                        </div>


                        <!--用户状态-->
                        <div class="form-group  col-md-10">
                            <label class="col-md-2 control-label" for="stocklinkman" style="text-align: center;line-height: 36px">联系人</label>
                            <div class="col-md-8">
                                <input class="form-control" id="stocklinkman" name="stocklinkman"
                                       placeholder="联系人" type="text">
                            </div>
                        </div>


                        <!--登入名-->
                        <div class="form-group col-md-10">
                            <label class="col-md-2 control-label" for="stockaddress" style="text-align: center;line-height: 36px">地址</label>
                            <div class="col-md-8">
                                <input class="form-control" id="stockaddress" name="stockaddress"
                                       placeholder="登入名" type="text">
                            </div>
                        </div>


                        <!--

         <th>电话</th>
         <th>email</th>
         <th>备注</th>
   -->

                        <!--电话-->
                        <div class="form-group col-md-10">
                            <label class="col-md-2 control-label" for="stockphone" style="text-align: center;line-height: 36px">电话</label>
                            <div class="col-md-8">
                                <input class="form-control " id="stockphone" maxlength="11"
                                       name="stockphone" placeholder="电话" type="tel">
                            </div>
                        </div>

                        <!--邮箱-->
                        <div class="form-group col-md-10">
                            <label class="col-md-2 control-label" for="stockemail" style="text-align: center;line-height: 36px">邮箱</label>
                            <div class="col-md-8">
                                <input class="form-control " id="stockemail" name="stockemail"
                                       placeholder="邮箱" type="email">
                            </div>
                        </div>



                        <!--备注-->
                        <div class="form-group col-md-10">
                            <label class="col-md-2 control-label" for="comment" style="text-align: center;line-height: 36px">备注</label>
                            <div class="col-md-8">
                                <input class="form-control " id="comment" name="comment"
                                       placeholder=".....备注....." type="text">
                            </div>
                        </div>

                        <div class="form-group col-md-10">
                            <button
                                    class="btn btn-primary ajax-post col-md-2"
                                    id="add-stock-btn"
                                    target-form="add-form"
                                    type="button">确 定
                            </button>
                            <button
                                    class="btn btn-default col-md-2"
                                    onclick="history.back(-1);return false;"
                                    type="button">返 回
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<div th:insert="common/fragment::tail-script"></div>

<script type="text/javascript">
    $(function () {


        // 添加仓库按钮提交 - addstock.ajax
        $('#add-stock-btn').on('click', function () {
            /**
             * private String name;
             private String address;
             private String linkman;
             private String phone;
             private String email;
             private String comment;
             * @type {*|jQuery}
             */

            let name = $('#stockname').val()
            let address = $('#stockaddress').val()
            let linkman = $('#stocklinkman').val()
            let phone = $('#stockphone').val()
            let email = $('#stockemail').val()
            let comment = $('#comment').val()

            /*// 1 检查仓库名
            if(name==''){
                confirmMsg("必须填写仓库名")
            }
            // 2 检查地址
            if(address==''){
                confirmMsg("必须填写地址")
            }*/

            let data = {
                name: name,
                phone: phone,
                email: email,
                address:address,
                linkman: linkman,
                comment: comment
            }
            //   let data = $('#icon-form').serialize()
            post_ajax('/stock/addstock.ajax', data, '/stock/stocklist.do');

        });
    });
</script>
</body>
</html>